package cn.com.bluemoon.daps.standard.dto;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * 数据规范
 * 指标数据格式	度量单位	取值精度	关联指标	关联维度	取值范围
 *
 * @author Jarod.Kong
 * @date 2020/8/27 16:31
 */
@Data
@Accessors
@EqualsAndHashCode
public class  IndStdExcelDataStandardDto {

    @TableField(exist = false)
    @ApiModelProperty(value = "指标类型")
    @Excel(name = "指标类型")
    private String indexTypeStr;

    /**
     * 校验是否符合
     */
    @ApiModelProperty(value = "指标格式， 数值、金额")
    @Excel(name = "指标数据格式")
    @NotNull(message = "指标数据格式不可为空", groups = {ExcelImportGroup.class})
    private String indexFormat;

    @ApiModelProperty(value = "度量单位")
    @Size(max = 20, message = "度量单位不可大于{max}", groups = {ExcelImportGroup.class})
    @Excel(name = "度量单位")
    private String commonUnits;

    @ApiModelProperty(value = "数据精度")
    @Excel(name = "取值精度")
    @Size(max = 100, message = "取值精度不可大于{max}", groups = {ExcelImportGroup.class})
    private String dataAccuracy;

    @ApiModelProperty(value = "关联指标")
    @Size(max = 200, message = "关联指标不可大于{max}", groups = {ExcelImportGroup.class})
    @Excel(name = "关联指标")
    private String relatedIndex;

    @ApiModelProperty(value = "关联维度")
//    @Size(max = 200, message = "关联维度不可大于{max}", groups = {ExcelImportGroup.class})
    @Excel(name = "关联维度") // 2021/9/23 关联维度（多个）用英文逗号隔开 -导入重构
    private String associationDimensionNames;

    @ApiModelProperty(value = "取值范围")
    @Excel(name = "取值范围")
    @Size(max = 100, message = "取值范围不可大于{max}", groups = {ExcelImportGroup.class})
    private String valueRange;

    /**
     * 要对数据长度进行约束
     * <code>
     *if (values.dataLength){
     *   let errorStartLeft = ['-', '(-', '（-']
     *   let dl = values.dataLength.trimLeft()
     *   let match = false
     *   for (let e of errorStartLeft) {
     *     if (dl.startsWith(e)){
     *       match = true
     *       break
     *     }
     *   }
     *   if (match) {
     *     that.$message.error(`请输入有效数据长度（长度不可为负数）`)
     *     return;
     *   }
     * }
     * </code>
     */
    @ApiModelProperty(value = "数据长度")
    @Excel(name = "数据长度")
    @Size(max = 20, min = 0, message = "数据长度不可大于{max}", groups = {ExcelImportGroup.class})
    private String dateLength;
}
